package fr.cie.blog.modeldao.hib;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import fr.cie.blog.beans.Config;
import fr.cie.blog.domainservice.IServiceConfig;

/**
 * @author AetM
 * 
 */
public class ConfigDaoImplHib extends HibernateDaoSupport implements
		IServiceConfig {

	/**
	 * Log4J the logger.
	 */
	private static final Logger LOG = Logger.getLogger(ConfigDaoImplHib.class);

	@Override
	public final int save(final Config config) {
		LOG.info("save pObject !!!!!" + config);
		getHibernateTemplate().save(config);
		return 0;
	}

	@Override
	public final int update(final Config config) {
		getHibernateTemplate().saveOrUpdate(config);
		return 0;
	}

	@Override
	public final int delete(final Config config) {
		getHibernateTemplate().delete(config);
		return 0;
	}

	@Override
	public final List<Config> findAll() {
		@SuppressWarnings("unchecked")
		final List<Config> list = (List<Config>) getHibernateTemplate().find(
				"from Config");
		return list;
	}

	@Override
	public final Config findById(final long pIdentifier) {
		return getHibernateTemplate().get(Config.class, pIdentifier);
	}

}